-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial Python Repo Manager #97
Conversation
Codecov Report
@@ Coverage Diff @@
## main #97 +/- ##
==========================================
+ Coverage 95.22% 95.51% +0.28%
==========================================
Files 51 60 +9
Lines 2285 2432 +147
==========================================
+ Hits 2176 2323 +147
Misses 109 109
|
1cb5118
to
78dbd68
Compare
the codecov failure isn't legitimate to me. It mentions lack of coverage on a file I didn't even touch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor changes. See comments.
) | ||
|
||
|
||
class SetupCallVisotor(cst.CSTVisitor): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Visotor -> Visitor
def clean_simplestring(node: cst.SimpleString | str) -> str: | ||
if isinstance(node, str): | ||
return node.strip('"') | ||
return node.value.strip('"') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use node.raw_value
. It will strip the quotes and prefixes.
These are good call-outs. I hope we can defer these until later and just try to handle the more "standard" cases for now.
A lot of really good points here too. I think the simplest heuristic will be to have some kind of priority order that we define in advance, and make updates only to the first of those files that we detect. We can build out more functionality from that point. It feels like we're paving a new path here, though, and we're on our own to figure it out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. I'm sure there is going to be a lot of iteration on this and the dependency manager, but this gives us a really good foundation to build upon. Just a few minor comments but otherwise 👍
self.directory = directory | ||
self.dry_run = dry_run | ||
self.verbose = verbose | ||
self._results_by_codemod = {} | ||
self._failures_by_codemod = {} | ||
self.dependencies = {} | ||
self.registry = registry | ||
self.repo_manager = repo_manager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minor thing but we should add the type declaration at the class definition above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you referring to something else that's not already line 43, repo_manager: PythonRepoManager,
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should be added on line 35 above too.
@property | ||
@abstractmethod | ||
def file_name(self): | ||
... # pragma: no cover |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a tiny thing but I think you can have the ...
on the same line as the def
which probably makes the # pragma
unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh I hope so!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
black doesn't like inline ... so I left it as is
src/codemodder/project_analysis/file_parsers/setup_cfg_file_parser.py
Outdated
Show resolved
Hide resolved
66f3c48
to
1ee9b1b
Compare
Overview
The purpose here is to kickstart the code for analyzing a project directory, its metadata and dependencies.
Description
PythonRepoManager
's goal is to take the parent directory passed to codemodder and to analyze that repo's files for existence of any pkg management system or dependency store, such as requirements.txt, project.toml, setup.py, setup.cfg, poetry's more special project.toml, Pipfile, conda's .yaml files.There is some key work that needs to happen going forward:
PythonRepoManager
withDependencyManager
. I think ideally DM will be inside PRM, but we shall see as a next step. There's quite a bit of changes going on to DM right now so I'd like to sandbox it